﻿using Dapr;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace Subscriber.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class OrdersController : ControllerBase
    {
        private readonly ILogger<OrdersController> _logger;

        public OrdersController(ILogger<OrdersController> logger)
        {
            _logger = logger;
        }
        [Topic("pubsub", "newOrder")]
        [HttpPost] 
        public ActionResult CreateOrder(OrderData  @event)
        {
           // _logger.LogInformation($"{DateTime.Now},{System.Text.Json.JsonSerializer.Serialize(@event.Data)}");
            Console.WriteLine(System.Text.Json.JsonSerializer.Serialize(@event));
            return Ok();
        }

        //[HttpPost] 
        //public ActionResult PostOrder(OrderData @event)
        //{
        //    _logger.LogInformation($"{DateTime.Now},{System.Text.Json.JsonSerializer.Serialize(@event)}");
        //    Console.WriteLine(System.Text.Json.JsonSerializer.Serialize(@event));
        //    return Ok();
        //}

    }
}
